﻿@using CNKI.TPI.Web.Base
@using CNKI.TPI.Web.Search.BLL
<script type="text/javascript">
    //<![CDATA[
    $(document).ready(function () {
        $.ajax({
            type: "GET",
            url: "@Html.Raw(Url.Action("IsFirstDigitalFileExsit", "File"))",
            data: { "dbID": $("#dbID").val(), "recordId": $("#recordId").val(), "MediaType": $("#mediaType").val() },
            success: function (msg) {
                if (msg == 0) {
                    $(".list-video").attr("style", "background-image:url('Images/videonone.png')");
                }
                else if (msg == 2) {
                    $(".list-video").attr("style", "background-image:url('Images/videosupport.png')");
                }
                else {
                    $(".list-video").attr("style", "background-image:none");
                    var addressmedia = $('#playaddress').val();
                    var picmedia = $('#playpic').val();
                    playfile(addressmedia, picmedia);
                }
            },
            error: function (e) {
                messageAlert("系统异常，请刷新后重试!")
            }
        })

    });
    function playvideo(sid, id, filename) {

        var datastr = { "dbID": id, "sysID": sid, "flage": 1 };
        var url = "";
        $.ajax({
            async: false,
            type: "get",
            url: timestamp("@Html.Raw(Url.Action("GetStreamUrl", "Detail"))"),
            data: datastr,
            success: function (msg) {
                url = msg;
            },
            error: function (e) {
                messageAlert("系统异常，请刷新后重试!")
            }
        })
        if (url == "0") {
            jwplayer().remove();
            $(".list-video").attr("style", "background-image:url('Images/videonone.png')");
        }
        else if (url == "2") {
            jwplayer().remove();
            $(".list-video").attr("style", "background-image:url('Images/videosupport.png')");
        }
        else {

            $(".list-video").attr("style", "background-image:none");
            playfile(url, "");
            //jwplayer().load({ file: url, type: "mp4", image: $('#playpic').val() });
            jwplayer().play();
        }
    }
    //解决浏览器缓存
    function timestamp(url) {
        var getTimestamp = new Date().getTime();
        if (url.indexOf("?") > -1) {
            url = url + "&t=" + getTimestamp
        } else {
            url = url + "?t=" + getTimestamp
        }
        return url;
    }

    function playfile(filepath, imgpath) {
        jwplayer('player').setup({
            file: filepath,
            type: "mp4",
            primary: "flash",
            image: imgpath,
            width: 650,
            height: 382
        })

    }

    //]]>
</script>
<div class="crumbLink">
    @*<a href="javascript:void(0);">首页</a>&gt;<a href="javascript:void(0);">检索</a>&gt;期刊*@

</div>
<h2 class='doc-title'>@Html.Raw(ColumnAliasHelper.GetContent(ViewBag.DetialField, 0, 0))</h2>
<div class="doc-value">
    @{
        string view = ColumnAliasHelper.GetContent(ViewBag.DetialField, @ViewBag.DbName, 0, "SYS_FLD_BROWSERATE");
        string download = ColumnAliasHelper.GetContent(ViewBag.DetialField, @ViewBag.DbName, 0, "SYS_FLD_DOWNLOADRATE");
    }
    浏览量：@Html.Raw(@view == "" ? "0" : @view)
    下载量：@Html.Raw(@download == "" ? "0" : @download)

    @{   int type = (int)MediaType.Video;
        if (SessionHelper.HasDownloadRight(ViewBag.dbId))
        {

            if (ViewBag.FileCount != null && ViewBag.FileCount > 1)
            {
                <a onclick="showdown()" class='btn btn-m btn-prim-f ml10'><i class="iconfont icon-download"></i>下载</a>
            }
            else
            {
                <a onclick="javascript:isDown(@ViewBag.dbId, @ViewBag.recordId,@type,'@Html.Raw(Url.Action("IsShowDown", "File"))','-1','@ViewBag.DownType')" class='btn btn-m btn-prim-f ml10'>
                    <i class="iconfont icon-download"></i>下载
                </a>
            }
        }
    }
    @if (SessionHelper.GetUserInfo() != null
            && ((ConfigHelper.IsAnonymousControlEnabled() && SessionHelper.GetUserInfo().UserCode.ToUpper() != ConfigHelper.GetAnonymousAccount().ToUpper())
            || !ConfigHelper.IsAnonymousControlEnabled()))
    {
        <span class="favCate">
            <a onclick="showFavCate('@ColumnAliasHelper.GetContent(ViewBag.DetialField, 0, 0)')" class='btn btn-m btn-prim-f ml10'><i class="iconfont icon-star"></i>收藏</a>
        </span>
    }
</div>
@* “视频下载”弹层 *@
<div class="talkDiv Down" style="top: 50%; left: 50%; margin-left: -280px; display: none">
    <div class="talkDiv-title" style="height: 40px; line-height: 40px; padding-left: 10px; font-size: 16px; position: relative; border-bottom: 1px solid #DADADA; background-color: #efefef; font-family: 微软雅黑">
        <span>下载</span>
        <a class="icon icon-close" title="关闭" href="javascript:void(0);" onclick="closedown()" style="top: 0px"><i class="iconfont icon-error3"></i></a>
    </div>
    <div class="talkDiv-body" style="padding-top: 25px">
        <ul class="video-download">
            @if (ViewBag.FileInfoAll != null)
            {
                foreach (CNKI.TPI.Web.Search.Model.METADATA_FILE m in ViewBag.FileInfoAll)
                {

                    <li>
                        @m.FILENAME
                    <a class="btn btn-m btn-prim-f posa" style="margin-right:40px"
                       onclick="javascript:isDown(@ViewBag.dbId, @ViewBag.recordId,@type, '@Html.Raw(Url.Action("IsShowDown", "File"))','@m.SYSID','@ViewBag.DownType')">点击下载</a>
                </li>
                }
            }

        </ul>
    </div>
</div>
<div class="doc-con clearfix posr video-con">
    <div class='video-con-r'>
        <div class="video-con-r-in">
            <P></P>
            @foreach (System.Data.DataRow dr in ViewBag.DetialField.Rows)
            {
                int i = 0;
                System.Data.DataRow columnInfo = null;
                foreach (System.Data.DataColumn column in ViewBag.DetialField.Columns)
                {
                    if (column.ColumnName.StartsWith("SYS_FLD_") || column.ColumnName == "浏览量" || i == 0)
                    {
                        i++;
                        continue;
                    }
                    columnInfo = ViewBag.RColumnInfo.Select(string.Format("Name='{0}'", column.ColumnName))[0];
                    string colname = column.ColumnName;
                    if (!string.IsNullOrEmpty(columnInfo["DispName"].ToString()))
                    {
                        colname = columnInfo["DispName"].ToString();
                    }
                    if (!string.IsNullOrEmpty(dr[column.ColumnName].ToString()))
                    {
                        <p>@colname：@Html.Raw(dr[column.ColumnName].ToString())</p>
                    }


                }
            }

        </div>
    </div>
    <div class='video-con-l'>
        <div class="tc posr list-video" style="text-align: left">

            <div id="player">
            </div>
        </div>
    </div>


</div>

<input type="hidden" id="dbID" name="dbID" value="@ViewBag.dbId" />
<input type="hidden" id="recordId" name="recordId" value="@ViewBag.recordId" />
<input type="hidden" id="mediaType" name="mediaType" value="@ViewBag.Type" />
<input type="hidden" id="playaddress" name="playaddress" value="@ViewBag.PlayStream" />
<input type="hidden" id="playpic" name="playpic" value="@ViewBag.Pic" />
<!-- 相似文献
<div class="xg-search xs-doc">
    <h2><span>在线播放</span></h2>
    <label style="color: red; font-size: 18px;" class="playmedia"></label>

</div>-->
<div class="center-box xg-search xs-doc new-push new-push1">
    <h2><span>在线播放列表</span></h2>

    <table class="table table-grey table-noedge" border="0" cellpadding="0" cellspacing="0" width="100%">
        <tbody>
            @{int Mp3num = 0, num = 0;}
            @if (ViewBag.FileInfo != null)
            {
                foreach (CNKI.TPI.Web.Search.Model.METADATA_FILE m in ViewBag.FileInfo)
                {
                    if (FileService.CheckVideo(m.FORMAT))
                    {
                        if (Mp3num % 3 == 0)
                        {
                            @Html.Raw("<tr><td><a onclick=\"playvideo('" + m.SYSID + "','" + @ViewBag.dbId + "','" + m.FILENAME + "')\">" + m.FILENAME + "</a></td>");
                        }
                        else if (Mp3num % 3 == 2 || num == ViewBag.FileInfo.Count)
                        {
                            @Html.Raw("<td><a onclick=\"playvideo('" + m.SYSID + "','" + @ViewBag.dbId + "','" + m.FILENAME + "')\">" + m.FILENAME + "</a></td></tr>");
                        }
                        else
                        {
                            @Html.Raw("<td><a onclick=\"playvideo('" + m.SYSID + "','" + @ViewBag.dbId + "','" + m.FILENAME + "')\">" + m.FILENAME + "</a></td>");
                        }
                        Mp3num++;
                    }
                    num++;
                }
            }
        </tbody>
    </table>

</div>


